package com.example.good.controller;

import com.example.good.util.JsonResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@RestController
public class RedirectController extends BaseController {

    @RequestMapping("jiangjiang")
    public JsonResult<String> redirect(
            HttpServletResponse response,
            HttpServletRequest request,
            HttpSession session
    ) throws IOException {
        session.setAttribute("uri",request.getRequestURI());
        response.sendRedirect("/");
        return null;
    }
    @RequestMapping("gogogo")
    public JsonResult<String> gogogo(HttpSession session){
        String data = (String) session.getAttribute("uri");
        System.out.println(data);
        return new JsonResult<String>(OK,data);
    }
}